# encoding: utf-8
# @File  : metrics.py
# @Author: shaoyun
# @Date  :  2025/05/11
from functools import wraps
import time
from loguru import logger

def measure_time(func):
    """
    性能监控装饰器，用于测量函数执行时间。
    """
    @wraps(func)
    async def wrapper(*args, **kwargs):
        start = time.time()
        result = await func(*args, **kwargs)
        duration = time.time() - start
        logger.debug(f"{func.__name__} executed in {duration:.2f} seconds")
        return result
    return wrapper